package com.yonyou.mybatis.controller;

import com.yonyou.mybatis.bean.Employee;
import com.yonyou.mybatis.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/emp")
public class EmployeeController {

	
	@Autowired
    EmployeeService employeeService;
	
	@RequestMapping("/getemps")
	public String emps(Map<String,Object> map){
		List<Employee> emps = employeeService.getEmps();
		map.put("allEmps", emps);
		return "list";
	}

	@RequestMapping("/saveEmployee")
	@ResponseBody
	public String saveEmployee(HttpServletRequest request){
		employeeService.saveEmployee(request);
		return "success";
	}
}
